/**
 * 
 */
package org.wolf.common.util;

import java.io.File;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;

/**
 * @author 何小锋
 * 
 */
public class ClassUtil {

	/**
	 * 获取资源
	 * 
	 * @param resource
	 * @return
	 */
	public static InputStream getResourceAsStream(String resource) {
		if (resource == null)
			return null;
		return ClassUtil.class.getClassLoader().getResourceAsStream(resource);
	}

	/**
	 * 获取资源
	 * 
	 * @param resource
	 * @return
	 */
	public static File getResourceAsFile(String resource) {
		if (resource != null) {
			URL url = ClassUtil.class.getClassLoader().getResource(resource);
			if (url != null) {
				try {
					return new File(url.toURI());
				} catch (URISyntaxException e) {
				}
			}
		}
		return null;
	}

}
